package oo.day01;
import java.util.Scanner;
public class CellGame {

	public static void main(String[] args) {
		//初始化墙和格
		Cell c = new Cell();
		c.row = 2;
		c.col = 5;
		System.out.println("Cell的位置:"+c.getCellInfo());
		printWall(c);
		//用户输入
		Scanner scan = new Scanner(System.in);
		do {
			System.out.println("请输入需要移动的方向：1下落一格,2左移一格,3右移一格,0退出");
			int input = scan.nextInt();
			moveCell(input,c);
			if(input == 0) {
				return;
			}
			System.out.println("Cell的位置:"+c.getCellInfo());
		}while(true);
	}

	//画墙和格
	public static void printWall(Cell c) {
		for(int i = 0; i < 20; i ++) {
			for(int j = 0; j < 10; j++) {
				if(i == c.row&& j == c.col) {
					System.out.print("* ");
				}else {
					System.out.print("- ");
				}
			}
			System.out.println();
		}
	}
	//移动
	public static void moveCell(int input,Cell c) {
		switch(input) {
		case 0:
			System.out.println("退出游戏");
			break;
		case 1:
			c.drop();
			printWall(c);
			break;
		case 2:
			c.moveLeft(1);
			printWall(c);
			break;
		case 3:
			c.moveRight(1);
			printWall(c);
			break;
		default:
			System.out.println("请输入正确的选项");
		}
	}
}
